/*
Illuminator (LED drawing tool for iPhone)
Copyright (C) 2008
Nik S Denin
Ivan A Vlasov
Dmitriy A Jackovlev

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#import "IlluminatorApp.h"

@implementation IlluminatorApp

- (void)applicationDidFinishLaunching:(GSEventRef)event
{
	// this line sets application full-screen
	[self setStatusBarMode:2 duration:0.0];
	
	NSFileManager *fileManager = [NSFileManager defaultManager];
	if (![fileManager fileExistsAtPath:HOMEDIR])
	{
		BOOL created = [fileManager createDirectoryAtPath:HOMEDIR attributes:nil];
		if (!created)
			TRACE(@"Failed to create %@.", HOMEDIR);
	}
	
	struct CGRect mainFrame = [UIHardware fullScreenApplicationContentRect];
	mainFrame.origin.x = mainFrame.origin.y = 0.0;
	mainFrame.size.width = 320.0;
	mainFrame.size.height = 480.0;

	m_window = [[UIWindow alloc] initWithContentRect:mainFrame];
	[m_window writeSnapshotsToDir:@"/tmp"];
	m_mainView = [[MainView alloc] initWithFrame:mainFrame];
	[m_window setContentView:m_mainView];
	[m_window orderFront:self];
}

- (void)applicationWillTerminate
{
	[m_mainView release];
	[m_window release];
}



@end // IlluminatorApp
